import {
  Column,
  Entity,
  JoinColumn,
  ManyToOne,
  PrimaryGeneratedColumn
} from 'typeorm';
import { CueParam } from './cue_param.entity';

@Entity('tb_cue_param_item')
export class CueParamItem {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ length: 255, comment: '参数项名称', name: 'item_name' })
  itemName: string;

  @Column({ length: 255, comment: '参数项字段中文名称', name: 'item_label' })
  itemLabel: string;

  @Column({ length: 255, comment: '参数项值', name: 'item_value' })
  itemValue: string;

  @Column({
    type: 'decimal',
    precision: 10,
    scale: 2,
    default: 0,
    comment: '价格'
  })
  price: number;

  @Column({
    length: 255,
    nullable: true,
    comment: '附件预览图URL',
    name: 'preview_url'
  })
  previewUrl?: string;

  @ManyToOne(() => CueParam, param => param.items)
  @JoinColumn({ name: 'param_id', referencedColumnName: 'id' })
  param: CueParam;
}
